package saxion.speelveld.spaceengineer.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class AchievementDB extends SQLiteOpenHelper
{
	public static final String TABLE_NAME = "achievement";

	public static final String COLUMN_ID = "_id";

	public static final String COLUMN_CAPTION = "title";

	public static final String COLUMN_EXPLANATION = "explanation";

	public static final String COLUMN_ACCOMPLISHED = "accomplished";

	private static final String DATABASE_FILENAME = "achievement.db";

	private static int DATABASE_VERSION = 1;

	public AchievementDB(Context context)
	{
		super(context, DATABASE_FILENAME, null, DATABASE_VERSION);
	}

	public AchievementDB(Context context, String name, CursorFactory factory, int version)
	{
		super(context, name, factory, version);
	}

	@Override
	public void onCreate(SQLiteDatabase db)
	{
		db.execSQL("create table " + TABLE_NAME +
			"(" + COLUMN_ID + " integer primary key autoincrement, "
			+ COLUMN_CAPTION + " text not null ,"
			+ COLUMN_EXPLANATION + " text not null, "
			+ COLUMN_ACCOMPLISHED + " integer not null);");

	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
	{
		db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
		onCreate(db);

	}

}
